// 导入 express
const express = require('express')
// 创建路由对象
const router = express.Router()


// 导入验证数据的中间件
const expressJoi = require('@escook/express-joi')
// 导入分类的验证模块
const { add_category_schema,  get_category_schema, update_category_schema, delete_category_schema } = require('../schema/websitecategory')

// 导入分类的路由处理函数模块
const websitecategory_handler = require('../router_handler/websitecategory')

// 获取分类的列表数据
router.get('/getcategory/:userId', websitecategory_handler.getWebsiteCategory)

// 新增分类的路由
router.post('/addcategory/:userId', expressJoi(add_category_schema), websitecategory_handler.addWebsiteCategory)


// 删除分类的路由
router.delete('/deletecategory/:id',   websitecategory_handler.deleteCategoryById)

//根据 Id 获取分类
router.get('/category/:id', expressJoi(get_category_schema), websitecategory_handler.getCategoryById)


// 更新分类的路由
router.post('/updatecategory',  expressJoi(update_category_schema), websitecategory_handler.updateCategoryById)


// 向外共享路由对象
module.exports = router
